package com.pirestupppai.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.pirestupppai.R;
import com.pirestupppai.base.BaseAdapter;
import com.pirestupppai.base.BaseViewHolder;
import com.pirestupppai.bean.FeedItem;
import com.pirestupppai.utils.ImageLoadUtil;

import java.util.List;

/**
 * 用户中心求P
 *
 * @author: xiaoluo
 * @date: 2017-04-21 11:10
 */
public class UserAskAdapter extends BaseAdapter<FeedItem> {
    private Context mContext;
    private List<FeedItem> mList;


    public UserAskAdapter(Context context, List<FeedItem> list) {
        super(list);
        this.mContext = context;
        this.mList = list;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_user_ask;
    }

    @Override
    protected void bindData(BaseViewHolder holder, int position) {
        ImageView askImage = holder.getView(R.id.user_ask_image);
        TextView askDescTv = holder.getView(R.id.user_ask_desc);
        TextView askTimeTv = holder.getView(R.id.user_ask_time);
        TextView askWorkCountTv = holder.getView(R.id.user_ask_work_count);

        final FeedItem item = mList.get(position);
        askTimeTv.setText(item.getTpTime());
        askDescTv.setText(item.getDesc());
        askWorkCountTv.setText(item.getReply_count() + "个作品");
        if (item.getMedias() != null && item.getMedias().size() != 0) {
            ImageLoadUtil.getInstance().loadImage(item.getMedias().get(0).getPathname(),
                    askImage, ImageLoadUtil.LoadOption.LOAD_MEDIUM);
        }
    }
}
